Skip to content

Computed properties and Watchers section translation #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 25, 2017

Conversation

panietoar
Copy link

No description provided.


Why do we need caching? Imagine we have an expensive computed property **A**, which requires looping through a huge Array and doing a lot of computations. Then we may have other computed properties that in turn depend on **A**. Without caching, we would be executing **A**’s getter many more times than necessary! In cases where you do not want caching, use a method instead.
Por qué necesitamos cacheo? Imagine que tenemos una costosa propiedad calculada **A**, la cual requiere iterar sobre un enorme Arreglo mientras realiza muchos cálculos. Luego podríamos tener otras propiedades calculadas que a su vez dependen de **A**. Sin caché, estaríamos ejecutando el getter de **A** muchas veces más de las necesarias! En casos donde no requiera caché, use un método.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tenemos una pauta para array establecida pero en este contexto podríamos usar colección y se entendería bien. Arreglo es un errror o un término nuevo para mi?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Un termino nuevo seguramente, así los he conocido desde que empecé a programar.
Lo cambiaré a colección.


Vue does provide a more generic way to observe and react to data changes on a Vue instance: **watch properties**. When you have some data that needs to change based on some other data, it is tempting to overuse `watch` - especially if you are coming from an AngularJS background. However, it is often a better idea to use a computed property rather than an imperative `watch` callback. Consider this example:
Vue de hecho provee una forma más genérica de observar y reaccionar a cambios de datos en una instancia Vue: **observar propiedades**. Cuando tiene datos que necesitan cambiar con base en otros datos, es tentador usar `watch`, especialmente si viene de un trasfondo de AngularJS. Sin embargo, es a menudo una mejor idea usar una propiedad calculada en vez de un callback `watch` imperativo. Considere el siguiente ejemplo:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

con base en otros datos me parece quer debería ser en base a otros datos.

methods: {
reverseMessage: function () {
return this.message.split('').reverse().join('')
}
}
```

Instead of a computed property, we can define the same function as a method instead. For the end result, the two approaches are indeed exactly the same. However, the difference is that **computed properties are cached based on their dependencies.** A computed property will only re-evaluate when some of its dependencies have changed. This means as long as `message` has not changed, multiple access to the `reversedMessage` computed property will immediately return the previously computed result without having to run the function again.
En vez de una propiedad calculada, podemos definir la misma función como un método. Para el resultado final, las dos formas son sin duda exactamente iguales. Sin embargo, la diferencia es que **las propiedades calculadas son cacheadas con base en sus dependencias.** Una propiedad calculada sólo será re-evaluada cuando alguna de sus dependencias haya cambiado. Esto quiere decir que mientras `message` no cambie, accesos múltiples a la propiedad calculada `reversedMessage` va a retornar inmediatamente el resultado calculado anteriormente sin tener que evaluar la función de nuevo.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

con base en sus dependencias me parece quer debería ser en base a sus dependencias.

@@ -154,11 +154,11 @@ var vm = new Vue({
})
```

Much better, isn't it?
Mucho mejor, no es cierto?
Copy link

@miljan-aleksic miljan-aleksic Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Falta el signo precedente.


### Computed Setter
### Setter calculado

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setter no está incluido en las pautas. Deberíamos decidir si es traducible o no y añadirlo.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Los getters y setters (interfaces, accesores, etc) son muy conocidos por los programadores, me atrevería a decir. Vue es un framework de javascript, eso supe unos conocimientos, al menos básicos, en programación.
Creo que la mayoría de desarrolladores reconoce los términos getter y setter como lenguaje común, y podremos usarlos sin problema.
En mi vida profesional jamás he escuchado que los llamen individualmente con un nombre en español.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Los he añadido en las pautas como términos no traducibles.

@panietoar
Copy link
Author

Comentarios realizados

@miljan-aleksic miljan-aleksic changed the title Computed properties and Watchers setcion translation Computed properties and Watchers section translation Aug 25, 2017
methods: {
reverseMessage: function () {
return this.message.split('').reverse().join('')
}
}
```

Instead of a computed property, we can define the same function as a method instead. For the end result, the two approaches are indeed exactly the same. However, the difference is that **computed properties are cached based on their dependencies.** A computed property will only re-evaluate when some of its dependencies have changed. This means as long as `message` has not changed, multiple access to the `reversedMessage` computed property will immediately return the previously computed result without having to run the function again.
En vez de una propiedad calculada, podemos definir la misma función como un método. Para el resultado final, las dos formas son sin duda exactamente iguales. Sin embargo, la diferencia es que **las propiedades calculadas son cacheadas en base en sus dependencias.** Una propiedad calculada sólo será re-evaluada cuando alguna de sus dependencias haya cambiado. Esto quiere decir que mientras `message` no cambie, accesos múltiples a la propiedad calculada `reversedMessage` va a retornar inmediatamente el resultado calculado anteriormente sin tener que evaluar la función de nuevo.
Copy link

@miljan-aleksic miljan-aleksic Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

en base a sus...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(
Jaja ok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


### Computed Setter
### Setter calculado

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Los he añadido en las pautas como términos no traducibles.

@miljan-aleksic miljan-aleksic merged commit 9db8ded into vuejs-es:master Aug 25, 2017
@panietoar panietoar deleted the computed-section branch August 25, 2017 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants